// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI, { Tag } from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'
import './font/iconfont.css'
import content from './content'
import promise from 'es6-promise'
// import echarts from 'echarts'
promise.polyfill()
Vue.use(content)
Vue.use(ElementUI)
// Vue.prototype.$echarts=echarts
Vue.config.productionTip = false
// axios.defaults.baseURL = 'http://192.168.251.174:8088'
// axios.defaults.baseURL = 'http://192.168.80.149:8080'
// axios.defaults.baseURL = 'http://192.168.80.152:8091'
axios.defaults.headers.post['Content-Type'] = 'application/json'
axios.defaults.baseURL = 'http://111.75.205.71:8091'
axios.defaults.withCredentials = true/* 解决跨域------axios.default.withCredentials */
Vue.prototype.$axios = axios/* 将axios挂在在vue上-------_this=this */
/* eslint-disable no-new */

//定义的全局方法
//审批部分是否有显示权限--------过八号无，县级无，审批过无
Vue.prototype.hasShengP = function(leval,state,rejected){
  //市级--
  var isV=true
  var _this = this
  isV = leval==1?false:true
  if(leval==2){
    var _this = this 
    var thisDate = (new Date()).getTime()
    this.$axios.get('/utilcontroller /getData',{params:{
          thisDate:thisDate
        }}).then(function(res){
          var data  = res.data.responseData;
          var Mouth = data.substr(0,6)//201810
          var Today = data//20181030
          // isV = Today<=(Mouth+'08')?true:false
          // isV = Today<=(Mouth+'16')?true:false
          isV = true
          if(!isV){
            //过了八号只有rejected为1且state为2时才显示
            // isV = (state==2&&rejected==1)?true:false
            isV = state==2?true:false//测试用
          }else{
              isV = state==2?true:false
          }
          _this.VshengP = isV
        })                 
  }else if(leval==3){
    //省级只有state为3时才显示审批
    isV= state==3?true:false
    _this.VshengP = isV
  }
  _this.VshengP = isV
}

//全局过滤器-
//--县级
Vue.filter('state1',function(value){
  switch(value){
    case '-1'://省驳回
    return '重新上报'
    break;
    case '0'://市驳回
    return '重新上报';
    break;
    case '1'://保存了但是没上报
    return '上报';
    break;
    case '2'://县级上报了
    return '待市审批';
    break;
    case '3':
    return '待省审批';
    break;
    case '4':
    return '省级通过'
    break;
    case '5':
    return '超时上报'
    break;
    case null://没上报
    return '上报'
  }
})
Vue.filter('statecol',function(value){
  switch(value){
    case '0':
    return 'warning';
    break;
    case '1':
    return 'warning';
    break;
    case '2':
    return 'warning';
    break;
    case '3':
    return '';
    break;
    case '4':
    return 'success'
    break;
    case '5':
    return 'danger'
    break;
  }
})
Vue.filter('state2',function(value){
  switch(value){
      case '0':
          return '市级驳回'
          break;
      case '-1':
          return '省级驳回'
          break;
      case '3':
          return '待省审批'
          break;
      case '4':
          return '省级通过'
          break;
      case '5':
           return '超时审批'
           break;
      default:
         return '网络错误'
  }
})
Vue.filter('state3',function(value){
  switch(value){
    case '0':
        return '市级驳回'
        break;
    case '-1':
        return '已驳回'
        break;
    case '4':
        return '省级通过'
        break;
    case '5':
        return '超时审批'
        break;
    }
})
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
